﻿using System;
using System.Collections.Generic;


namespace DailyFx.Book
{
	public interface IBook : IDisposable
	{

		/// <summary>
		///		Gets the root path of the book .
		/// </summary>
		String Root { get; }

		/// <summary>
		///		Gets the label of this book .
		/// </summary>
		String Label { get; }


		/// <summary>
		///		Gets all table metrics info .
		/// </summary>
		IReadOnlyList<Metrics> Metrics { get; }

		/// <summary>
		///		Gets all symbol definition . 
		/// </summary>
		IReadOnlyList<Symbol> Symbols { get; }

		/// <summary>
		///		Gets all table schemas .
		/// </summary>
		IReadOnlyList<Schema> Schemas { get; }



		/// <summary>
        ///     Creates a new book of specified path .
        /// </summary>
        void createBook ( string path, string label, bool overwriteIfExsits );

		/// <summary>
        ///     Opens the book with specified path .
        /// </summary>
        bool openBook (string path, string label );

		/// <summary>
        ///     Closes the book that is already opened .
        /// </summary>
        void closeBook ( bool applyChanges );



		/// <summary>
		///		Checks if the table of given label already exists .
		/// </summary>
		bool hasTable ( string label );

		/// <summary>
		///		Gets the table of specified label .
		/// </summary>
		ITable getTable ( string label );

		/// <summary>
		///		Creates a new table of specified label 
		///		and copying the schema structure and records' data from memory pool . 
		/// </summary>
		ITable createTable ( string label, Schema schema, bool overwriteIfExists );

		/// <summary>
		///		Deletes the table of specified label. 
		///		Operation gonna be failed If the table does not exist or is in use (opened) . 
		/// </summary>
		bool deleteTable ( string label );

		/// <summary>
		///		Creates new table "target" by copying both structure and data from the table "source".
		/// </summary>
		ITable copyTable ( string target, string source, bool overwriteIfExists );


	
		/// <summary>
		///		Creates a schema, which'll be used for creating new tables in the book. 
		/// </summary>
		bool createSchema ( string alias, Schema schema );

		/// <summary>
		///		Deletes the schema of specified alias .
		/// </summary>
		bool deleteSchema ( string alias );

		/// <summary>
		///		Gets the schema by specified alias .
		/// </summary>
		Schema getSchema ( string alias );


		/// <summary>
		///		Adds a new symbol of security to database .
		/// </summary>
		void addSymbol ( Symbol symbol );

		/// <summary>
		///		Deletes the symbol from database .
		/// </summary>
		bool deleteSymbol ( string code );

		/// <summary>
		///		Gets the symbol of specified code( identifier ) .
		/// </summary>
		Symbol getSymbol ( string code );

	}
}
